<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			.likebtn{
				background: #FF69B4;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<like msg="0"></like>
			<like msg="0"></like>
			<like msg="0"></like>
			<like msg="0"></like>
		</div>
	</body>
	<script type="text/javascript" src="js/vue.js" ></script>
	<script>
		Vue.component('like',{
			template:'<button :class="{likebtn:liked}" @click="toggleLike()">{{count}}赞</button>',
			props:['msg'],
			data:function(){
				return {
					liked:false,
					count:this.msg
				}
			},
			methods:{
				toggleLike:function(){
					this.liked=true
					if(this.liked==true)
					{
						this.count++
					}
				}
			}
		});
		//作业 ：点赞变成粉色 ，一直加1     赞1  赞5
		
		new Vue({
			el:"#app",
			data:{
			
			}
		});

	</script>
</html>
